We are attempting to update the texture on a node. The code below works correctly when we use a color, but it encounters issues when we attempt to use an image. The image is available in the bundle, and it image correctly in other parts of our application. This texture is being applied to both the floor and the wall. Please assist us with this issue."
for obj in Floor_grp[0].childNodes {
let node = obj.flattenedClone()
node.transform = obj.transform
let imageMaterial = SCNMaterial()
node.geometry?.materials = [imageMaterial]
node.geometry?.firstMaterial?.diffuse.contents = UIColor.brown
obj.removeFromParentNode()
Floor_grp[0].addChildNode(node)
}
Post
Replies
Boosts
Views
Activity
We scan the room using the RoomPlan API, and after the scan, we obtain objects with a white color along with shadows and shading. However, upon updating the color of these objects, we experience a loss of shadows and shading.
RoomPlan scan
After Update
I am currently working on a project involving the merging of multiple scans into a single structure using Room plan json file. I am facing an issue and would greatly appreciate your assistance in resolving it.
The problem I am encountering is as follows:
"Cannot process multiFloorPlan: Invalid room location in structure"
Captured room json file paths:
[https://mimesisfbs.s3.ap-south-1.amazonaws.com/project_3dfile_json/2088a003-5712-4e9f-91eb-601b145ca98e-project_3dfile_json_file.json)
[https://mimesisfbs.s3.ap-south-1.amazonaws.com/project_3dfile_json/10ccd0d9-7843-41bd-a021-a57781231059-project_3dfile_json_file.json)
We are using same code as in example.
[https://developer.apple.com/documentation/RoomPlan/merging_multiple_scans_into_a_single_structure)
We have a 'roomplan' API object in a USDZ file that we need to display as a mesh object. Please suggest how to convert it.
I am writing to seek assistance with a challenge I am facing while working on a 3D model rendering project. I believe your expertise in this area could be immensely helpful in resolving the issue.
The problem I am encountering involves difficulties in displaying textures on both parent and child nodes within the 3D model. Here are the key details of the problem:
This model contents wall_grp(doors, windows and wall) objects. We are using roomplan data in SCNView.
This code dependent on scene kit and room plan apis
When we are comment childnode code its working but in this case we don’t have windows and door on wall.
func updateWallObjects() {
if arch_grp.count > 0 {
if !arch_grp.isEmpty {
for obj in arch_grp[0].childNodes {
let color = UIColor.init(red: 255/255, green: 229/255, blue: 204/255, alpha: 1.0)
let parentNode = obj.flattenedClone()
for childObj in obj.childNodes {
let childNode = childObj.flattenedClone()
let childMaterial = SCNMaterial()
childNode.geometry?.materials = [childMaterial]
if let name = childObj.name {
if (removeNumbers(from: name) != "Wall") {
childNode.geometry?.firstMaterial?.diffuse.contents = UIColor.white
} else {
childNode.geometry?.firstMaterial?.diffuse.contents = color
}
}
childObj.removeFromParentNode()
parentNode.addChildNode(childObj)
}
let material = SCNMaterial()
parentNode.geometry?.materials = [material]
parentNode.geometry?.firstMaterial?.diffuse.contents = color
obj.removeFromParentNode()
arch_grp[0].addChildNode(parentNode)
}
}
}
}```
Please suggest us
We are using the RoomPlan API to capture data, which is stored in the 'CapturedRoom' variable in our code (referred to as 'finalResult'). We then attempt to save a USDZ file in the file manager. Sometimes it works, but other times, we encounter issues like the one below
Coding Error: in _IsValidPathForCreatingPrim at line 3338 of usd/stage.cpp -- Path must be an absolute path: <>
cannotCreateNode(path: "/9EE71ED0F8D6415496A7B9F0C3671DB0321")
This is that code we are using for shaving CapturedRoom data
func saveFileLocal() {
if let finalResult {
let fm = FileManager.default
let documentsURL = fm.urls(for: .documentDirectory, in: .userDomainMask).first!
//let documentsURL = URL.documentsDirectory
let fileName = "\(UUID().uuidString).usdz"
let fileURL = documentsURL.appendingPathComponent(fileName)
do {
try finalResult.export(to: fileURL)
} catch {
print(error)
}
}
}
Please help us.
We are trying to save usdz file in file manager some time its saved but some time we are getting the error. Like: path.absoluteURL file:///var/mobile/Containers/Data/Application/6D14A430-47B4-45F2-9D0D-6C31588A6A03/Documents/2896837C-C7E0-4FA8-BFE2-21A59B26D801.usdz Warning: in SdfPath at line 151 of sdf/path.cpp -- Ill-formed SdfPath </2896837CC7E04FA8BFE221A59B26D801>: syntax error Coding Error: in _IsValidPathForCreatingPrim at line 3338 of usd/stage.cpp -- Path must be an absolute path: <> cannotCreateNode(path: "/2896837CC7E04FA8BFE221A59B26D801")
func saveFileLocal() {
if let finalResult {
let fm = FileManager.default
var path = fm.urls(for: .documentDirectory, in: .userDomainMask).first!
let fileName = "(UUID().uuidString).usdz"
path.appendPathComponent(fileName)
do {
try finalResult.export(to: path.absoluteURL)
}
catch{
print(error)
}
}
}
func removeFiles() {
var filePath = ""
let fm = FileManager.default
let path = fm.urls(for: .documentDirectory, in: .userDomainMask).first!
do{
let content = try fm.contentsOfDirectory(atPath: path.path)
for c in content{
filePath = path.appendingPathComponent(c).absoluteString
if let url = URL(string: filePath){
try fm.removeItem(at: url)
}
}
}
catch{
print(error)
}
}